/*This file is part of Legend of the Dark Blade.

    Legend of the Dark Blade is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Legend of the Dark Blade is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser Public License for more details.

    You should have received a copy of the GNU Lesser Public License
    along with Legend of the Dark Blade.  If not, see <http://www.gnu.org/licenses/>.*/

#ifndef _GLOBAL_H
#define _GLOBAL_H

#include <string>
using std::string;
#include <math.h>
#include <iostream>
#include <fstream>

using namespace std;

#include <SDL/SDL.h>

#include "global.h"

#include "player.h"
#include "map.h"


extern void apply_surface(int x, int y, SDL_Surface* source, SDL_Surface* destination, SDL_Rect* clip = NULL, int alpha=255);
extern bool circlecollide(int c1_x,int c1_y,int c1_radius,int c2_x,int c2_y,int c2_radius);
extern bool boxcollide(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2 );

extern void load_file( );

extern int iter;

extern int cam_x;
extern int cam_y;

extern int spawn_x;
extern int spawn_y;
//extern int map [30] [22];


extern SDL_Surface *screen;

extern SDL_Surface* BG;
extern SDL_Surface* HUD;
extern SDL_Surface* life;
extern SDL_Surface* power;

extern SDL_Surface* player;
extern SDL_Rect pclip[ 20 ];

extern SDL_Surface* tilesheet;
extern SDL_Rect clip[ 40 ];

extern SDL_Surface* orb;

#define WAITTIME        15

#define SCREENW         640
#define SCREENH         480

#define PH				48		//Player height
#define PW				32		//Player width
#define PHTRIM          46      //PH-PTTRIM-PBTRIM
#define PWTRIM          12      //PW-PLTRIM-PRTRIM
#define PLTRIM          10
#define PRTRIM          10
#define PTTRIM          2
#define PBTRIM          0

#define VELMOVING		3.0f		//max velocity (speed) for moving left, right
#define VELTERMVEL      10.0f        //terminal velocity for falling
#define VELMOVINGADD	0.17f        //acceleration
#define VELJUMP			5.0f		//velocity for jumping
#define VELSUPERJUMP	10.0f		//super jump
#define VELPUSHBACK		0.0f
#define VELMOVINGFRICTION 0.1f      //friction

#define	GRAVITATION		0.25f        //gravity

#define MAPWIDTH		2000
#define MAPHEIGHT		15
#define TILEWIDTH		32
#define TILEHEIGHT      32

//#define PREVIEWTILESIZE	16			//size of the preview tiles
//#define THUMBTILESIZE	8			//size of the thumbnail tiles

#endif
